<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
<style>
    div{
        background: aliceblue;
    }

    table {
        border-collapse: collapse;
    }
    table, th, td {
        border: 1px solid black;
    }
</style>
<title></title>
</head>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<body>
<div id="test">

</div>
<script type="text/javascript">
        window.οnlοad=function(){
        //js代码请求

        }

        var urlip ="10.170.66.24:10133"

        function adddata(e) {
            console.log(e)
            console.log("fdgfdg", e.target.parentNode.parentNode.childNodes[0].innerHTML)

            console.log("aaaaaa", e.target.parentNode.parentNode.childNodes[3].innerHTML)




            var resType = document.getElementById(e.target.parentNode.parentNode.childNodes[0].innerHTML).value

            $.ajax({
                method:"get",
                //url:"http://127.0.0.1:8080/ems/add-ems?emsName="+e.target.parentNode.parentNode.childNodes[0].innerHTML+"&resType="+resType,
                url:"http://"+urlip+"/ems/add-ems?emsName="+e.target.parentNode.parentNode.childNodes[0].innerHTML+"&resType="+resType,
                //url:"http://127.0.0.1:8080/ems/get-emsList",
                data:{},
                dataType: "json",
                success : function(data) {
                    console.log(111111);
                    location = `test.html`;
                },
                error : function(msg) {
                }
            });
        }

        function deldata(e) {
            console.log("fdgfdg", e.target.parentNode.parentNode.childNodes[0].innerHTML)
            var resType = document.getElementById(e.target.parentNode.parentNode.childNodes[0].innerHTML).value

            $.ajax({
                method:"get",
                //url:"http://127.0.0.1:8080/ems/del-ems?emsName="+e.target.parentNode.parentNode.childNodes[0].innerHTML+"&resType="+resType,
                url:"http://"+urlip+"/ems/del-ems?emsName="+e.target.parentNode.parentNode.childNodes[0].innerHTML+"&resType="+resType,
                //url:"http://127.0.0.1:8080/ems/get-emsList",
                data:{},
                dataType: "json",
                headers: {
                    'asd':'qqq'
                },
                success : function(data) {
                    console.log(111111);
                    location = `test.html`;
                },
                error : function(msg) {
                }
            });

        }




        $(function(){
        $.ajax({
        method:"get",
        //url:"http://app-monitor.com:10133/ems/get-emsList",
        url:"http://"+urlip+"/ems/get-emsList",
        //url:"http://127.0.0.1:8080/ems/get-emsList",
        data:{},
        dataType: "json",

        success: function(data){

            var str="<table>"
                $.each(data.data,function (i,items){
                    str+="<tr><td bgcolor=#ffa600>"+items.emsName+"</td>"
                    str+="<td bgcolor=#ffa600>"+items.deployer+  "</td>"
                    str+="<td>"
                    $.each(items.resList,function (i,fff) {
                        str+=fff
                        str+="  ,  "
                    });
                    str+="</td><td><input id="+items.emsName+" type='text' name='restype'></td><td><button onclick='adddata(event)'>add</button></td><td><button onclick='deldata(event)'>del</button></td>" +
                        "</tr>"
                })
                str+="</table>"

                str+="<h3>监控文件路径：/data10/YG/TRANS</h3>"

        $("div").append(str);
        }

        });

        })
</script>
</body>
</html>


